package com.javaxiaobang.controller;

import com.javaxiaobang.dao.PoDictionaryMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.locks.LockSupport;

/**
 * 功    能：
 * 作    者：tianqiang
 * 时    间：2019/11/15
 */
@Slf4j
@RestController
@RefreshScope //刷新配置中心：1.销毁相关的bean 2.重新加载相关bean
public class MainController {


    @Value("${name}")
    private String name;

    @Value("${password}")
    private String password;

    @Value("${testDecode}")
    private String testDecode;

    @Value("${server.port}")
    private String serverPort;

    @Value("${age}")
    private String age;

    @Autowired
    private PoDictionaryMapper poDictionaryMapper;


    @GetMapping("")
    public Object index() {
        log.info("name:{}", name);
        log.info("password:{}", password);
        log.info("age:{}", age);
        log.info("testDecode:{}", testDecode);
        log.info("*************************************************");
        return this.age;
    }

    @GetMapping("getDictList")
    public Object getDictList() {
        log.info("当前服务器端口:{}", serverPort);
//        try{
//            Thread.sleep(2000);
//        }catch (Exception e){
//        }
        return poDictionaryMapper.getDictList();
    }

    @GetMapping("getDictMap")
    public Object getDictMap() {
        log.info("当前服务器端口:{}", serverPort);
        return poDictionaryMapper.getDictMap();
    }

    @GetMapping("/javaxiaobang/getDictList")
    public Object getDictFeiginList() {
        log.info("{}当前服务器端口1:{}","getDictFeiginList", serverPort);
//        try{
//            Thread.sleep(2000);
//        }catch (Exception e){
//        }
        return poDictionaryMapper.getDictList();
    }

    @GetMapping("/javaxiaobang/getDictMap")
    public Object getDictFeiginMap() {
        log.info("{}当前服务器端口:{}","getDictFeiginMap", serverPort);
        return poDictionaryMapper.getDictMap();
    }

}
